from apps.goods.models import GoodsCategory,GoodsChannel,GoodsChannelGroup
from rest_framework.serializers import ModelSerializer
from rest_framework import serializers


class GoodsCategoryModelSerializer(ModelSerializer):
    """商品一级分类序列化器"""

    class Meta:
        model = GoodsCategory
        fields=('id','name')



class GoodsChannelModelSerializer(ModelSerializer):
    """商品频道组序列化器"""

    category=serializers.StringRelatedField()
    category_id=serializers.IntegerField()
    group=serializers.StringRelatedField()
    group_id=serializers.IntegerField()
    class Meta:
        model= GoodsChannel
        fields='__all__'


class GoodsChannelGroupModelSerializer(ModelSerializer):
    """频道组序列化器"""

    class Meta:
        model=GoodsChannelGroup
        fields=('id','name')
